<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>借阅列表</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- 引入 Bootstrap -->
  <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <style>
    .backBookSuccess{
      display: none;
    }
    .backBookFail{
      display: block;
    }
  </style>
</head>
<body>


<div class="container"><script type="text/javascript">

  window.onload=function(){
    var qs = location.search;
    let msg = decodeURI(qs);
    let l = msg.substr(1)
    let l1= l.split("=")[1]
    if (l1 !== undefined) {
      alert(l1);
    }
  }
</script>
  <div class="row clearfix">
    <div class="col-md-12 column">
      <div class="page-header">
        <h1>
          <small>借阅列表 —— 显示当前用户借阅信息</small>
        </h1>
        <a style="float: right" href="${pageContext.request.contextPath}/login/exportLendList">导出excel表</a>
      </div>
    </div>
  </div>

  <div class="row">
  </div>

  <div class="row clearfix">
    <div class="col-md-4 column">
      <a class="btn btn-primary" href="${pageContext.request.contextPath}/lendListIndex">返回</a>
    </div>
    <div class="col-md-12 column">
      <table class="table table-hover table-striped">
        <thead>
        <tr>
          <th>编号</th>
          <th>书名</th>
          <th>借阅者</th>
          <th>借书日期</th>
          <th>还书日期</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
        </thead>

        <tbody>
        <c:forEach var="lendList" items="${pageInfo.list}">
          <tr>
            <td>${lendList.lendId}</td>
            <td>${lendList.bookName}</td>
            <td>${lendList.userName}</td>
            <td><fmt:formatDate value="${lendList.lendDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
            <td><fmt:formatDate value="${lendList.backDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
            <td>${lendList.status}</td>
            <td>
              <a href="${pageContext.request.contextPath}/login/delLend/${lendList.getLendId()}/${lendList.bookName}">还书</a>
            </td>
          </tr>
        </c:forEach>
        </tbody>
      </table>
    </div>
    <div class="box-tools pull-right">
      <ul class="pagination">
        <li><a href="${pageContext.request.contextPath}/login/backBook?page=1&size=5"
               aria-label="Previous">首页</a></li>
        <li>
          <a href="${pageContext.request.contextPath}/login/backBook?page=${pageInfo.pageNum-1}&size=5">上一页</a>
        </li>
        <c:forEach begin="1" end="${pageInfo.pages}" var="pageNum">
          <li>
            <a href="${pageContext.request.contextPath}/login/backBook?page=${pageNum}&size=5">${pageNum}</a>
          </li>
        </c:forEach>
        <li>
          <a href="${pageContext.request.contextPath}/login/backBook?page=${pageInfo.pageNum+1}&size=5">下一页</a>
        </li>
        <li><a href="${pageContext.request.contextPath}/login/backBook?page=${pageInfo.pages}&size=5"
               aria-label="Next">尾页</a></li>
      </ul>
    </div>
  </div>
</div>
</body>
</html>